package org.hawk.gwt.ppc.parser;

import org.hawk.gwt.ppc.utils.PreprocessorException;


/**
 * Represents token(s) interpretation. Different tokens and token groups may be interpreted in different way.
 * This is base interface for such an interpretations.
 * 
 * @author alex.bereznevatiy@gmail.com
 */
public interface Descriptor {

	/**
	 * @return compilation unit this descriptor belongs to.
	 */
	CompilationUnitDescriptor getCompilationUnit();
	
	/**
	 * Visits every single node in this abstract syntax subtree.
	 * It is guaranteed that {@link DescriptorVisitor#visit(Descriptor)} method will be
	 * call once and only once for this descriptor and every descriptor of this descriptor.
	 * @param visitor
	 * @throws PreprocessorException in case of troubles
	 */
	void visit(DescriptorVisitor visitor) throws PreprocessorException;
	
	/**
	 * @return first token associated with this descriptor
	 */
	Token getFirstToken();
	
	/**
	 * @return last token associated with this descriptor
	 */
	Token getLastToken();

	/**
	 * @param line
	 * @param offset
	 * @return <code>true</code> if this descriptor contains token with parameters passed. 
	 */
	boolean hasToken(int line, int offset);
}
